home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 144 / cd-rom 144.iso / aplic / class / data1.cab / Executaveis / janela.swf / scripts / __Packages / mx / containers / Window.as
Encoding:
Text File  |  2007-05-19  |  8.3 KB  |  275 lines

  1. class mx.containers.Window extends mx.core.ScrollView
  2. {
  3.    var __contentPath;
  4.    var boundingBox_mc;
  5.    var modalWindow;
  6.    var regX;
  7.    var regY;
  8.    var onMouseMove;
  9.    var back_mc;
  10.    var depth;
  11.    var titleStyleDeclaration;
  12.    var button_mc;
  13.    var validateNow;
  14.    var _title;
  15.    var _child0;
  16.    var border_mc;
  17.    var vScroller;
  18.    var hScroller;
  19.    var closeButton;
  20.    var dispatchEvent;
  21.    static var symbolName = "Window";
  22.    static var symbolOwner = mx.containers.Window;
  23.    static var version = "2.0.2.126";
  24.    var className = "Window";
  25.    static var skinIDBorder = 0;
  26.    static var skinIDTitleBackground = 1;
  27.    static var skinIDForm = 2;
  28.    var idNames = new Array("border_mc","back_mc","content");
  29.    var skinTitleBackground = "TitleBackground";
  30.    var skinCloseUp = "CloseButtonUp";
  31.    var skinCloseOver = "CloseButtonOver";
  32.    var skinCloseDown = "CloseButtonDown";
  33.    var skinCloseDisabled = "CloseButtonDisabled";
  34.    var clipParameters = {title:1,contentPath:1,closeButton:1};
  35.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.containers.Window.prototype.clipParameters,mx.core.ScrollView.prototype.clipParameters);
  36.    var initializing = true;
  37.    var loadingChild = false;
  38.    function Window()
  39.    {
  40.       super();
  41.    }
  42.    function set contentPath(scrollableContent)
  43.    {
  44.       if(!this.initializing)
  45.       {
  46.          if(scrollableContent == undefined)
  47.          {
  48.             this.destroyChildAt(0);
  49.          }
  50.          else
  51.          {
  52.             if(this[mx.core.View.childNameBase + 0] != undefined)
  53.             {
  54.                this.destroyChildAt(0);
  55.             }
  56.             this.createChild(scrollableContent,"content",{styleName:this});
  57.          }
  58.       }
  59.       this.__contentPath = scrollableContent;
  60.    }
  61.    function get contentPath()
  62.    {
  63.       return this.__contentPath;
  64.    }
  65.    function init(Void)
  66.    {
  67.       super.init();
  68.       this.boundingBox_mc._visible = false;
  69.       this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  70.    }
  71.    function delegateClick(obj)
  72.    {
  73.       this._parent.dispatchEvent({type:"click"});
  74.    }
  75.    function startDragging(Void)
  76.    {
  77.       if(this.modalWindow == undefined)
  78.       {
  79.          var _loc2_ = this._parent.createChildAtDepth("BoundingBox",mx.managers.DepthManager.kTop,{_visible:false});
  80.          this.swapDepths(_loc2_);
  81.          _loc2_.removeMovieClip();
  82.       }
  83.       this.regX = this._xmouse;
  84.       this.regY = this._ymouse;
  85.       this.onMouseMove = this.dragTracking;
  86.    }
  87.    function stopDragging(Void)
  88.    {
  89.       delete this.onMouseMove;
  90.    }
  91.    function dragTracking()
  92.    {
  93.       var _loc5_ = this._parent._xmouse - this.regX;
  94.       var _loc4_ = this._parent._ymouse - this.regY;
  95.       var _loc3_ = 5;
  96.       var _loc2_ = mx.managers.SystemManager.screen;
  97.       if(_loc5_ < _loc2_.x - this.regX + _loc3_)
  98.       {
  99.          _loc5_ = _loc2_.x - this.regX + _loc3_;
  100.       }
  101.       if(_loc5_ > _loc2_.width + _loc2_.x - (this.regX + _loc3_))
  102.       {
  103.          _loc5_ = _loc2_.width + _loc2_.x - (this.regX + _loc3_);
  104.       }
  105.       if(_loc4_ < _loc2_.y - this.regY + _loc3_)
  106.       {
  107.          _loc4_ = _loc2_.y - this.regY + _loc3_;
  108.       }
  109.       if(_loc4_ > _loc2_.height + _loc2_.y - (this.regY + _loc3_))
  110.       {
  111.          _loc4_ = _loc2_.height + _loc2_.y - (this.regY + _loc3_);
  112.       }
  113.       this.move(_loc5_,_loc4_);
  114.       updateAfterEvent();
  115.    }
  116.    function createChildren(Void)
  117.    {
  118.       super.createChildren();
  119.       if(this.back_mc == undefined)
  120.       {
  121.          this.createClassObject(mx.core.UIObject,"back_mc",1);
  122.          this.back_mc.createObject(this.skinTitleBackground,"back_mc",0);
  123.       }
  124.       this.back_mc.visible = false;
  125.       this.depth = 3;
  126.       var _loc6_ = new Object();
  127.       this.back_mc.useHandCursor = false;
  128.       this.back_mc.onPress = function()
  129.       {
  130.          if(this._parent.enabled)
  131.          {
  132.             this._parent.startDragging();
  133.          }
  134.       };
  135.       this.back_mc.onDragOut = this.back_mc.onRollOut = this.back_mc.onReleaseOutside = this.back_mc.onRelease = function()
  136.       {
  137.          var _loc2_ = this._parent;
  138.          _loc2_.stopDragging();
  139.       };
  140.       this.back_mc.tabEnabled = false;
  141.       if(this.back_mc.title_mc == undefined)
  142.       {
  143.          this.back_mc.createLabel("title_mc",1,this.title);
  144.          var _loc4_ = this.back_mc.title_mc;
  145.          if(this.titleStyleDeclaration == undefined)
  146.          {
  147.             _loc4_.fontSize = 10;
  148.             _loc4_.color = 16777215;
  149.             _loc4_.fontWeight = "bold";
  150.          }
  151.          else
  152.          {
  153.             _loc4_.styleName = this.titleStyleDeclaration;
  154.          }
  155.          _loc4_.invalidateStyle();
  156.       }
  157.       else
  158.       {
  159.          this.back_mc.title_mc.text = this.title;
  160.       }
  161.       var _loc3_ = new Object();
  162.       _loc3_.falseUpSkin = this.skinCloseUp;
  163.       _loc3_.falseOverSkin = this.skinCloseOver;
  164.       _loc3_.falseDownSkin = this.skinCloseDown;
  165.       _loc3_.falseDisabledSkin = this.skinCloseDisabled;
  166.       _loc3_.tabEnabled = false;
  167.       this.createClassObject(mx.controls.SimpleButton,"button_mc",2,_loc3_);
  168.       this.button_mc.clickHandler = this.delegateClick;
  169.       this.button_mc.visible = false;
  170.       if(this.validateNow)
  171.       {
  172.          this.redraw(true);
  173.       }
  174.       else
  175.       {
  176.          this.invalidate();
  177.       }
  178.    }
  179.    function get title()
  180.    {
  181.       return this._title;
  182.    }
  183.    function set title(s)
  184.    {
  185.       this._title = s;
  186.       this.back_mc.title_mc.text = s;
  187.       if(!this.initializing)
  188.       {
  189.          this.draw();
  190.       }
  191.    }
  192.    function setEnabled(enable)
  193.    {
  194.       super.setEnabled(enable);
  195.       this.button_mc.enabled = enable;
  196.       this._child0.enabled = enable;
  197.    }
  198.    function getComponentCount(Void)
  199.    {
  200.       return 1;
  201.    }
  202.    function getComponentRect(container)
  203.    {
  204.       if(container == 1)
  205.       {
  206.          var _loc3_ = this.border_mc.borderMetrics;
  207.          var _loc2_ = new Object();
  208.          _loc2_.x = _loc3_.left;
  209.          _loc2_.y = _loc3_.top + this.back_mc.height;
  210.          _loc2_.width = this.width - _loc2_.x - _loc3_.right;
  211.          _loc2_.height = this.height - _loc2_.y - _loc3_.bottom;
  212.          return _loc2_;
  213.       }
  214.       return undefined;
  215.    }
  216.    function draw(Void)
  217.    {
  218.       if(this.initializing)
  219.       {
  220.          this.initializing = false;
  221.          if(this.__contentPath != undefined)
  222.          {
  223.             this.contentPath = this.__contentPath;
  224.          }
  225.          this._child0.visible = true;
  226.          this.border_mc.visible = true;
  227.          this.back_mc.visible = true;
  228.       }
  229.       this.size();
  230.    }
  231.    function getViewMetrics(Void)
  232.    {
  233.       var _loc3_ = super.getViewMetrics();
  234.       _loc3_.top += this.back_mc.height;
  235.       return _loc3_;
  236.    }
  237.    function doLayout(Void)
  238.    {
  239.       super.doLayout();
  240.       var _loc3_ = this.border_mc.borderMetrics;
  241.       _loc3_.right += this.vScroller.visible != true ? 0 : this.vScroller.width;
  242.       _loc3_.bottom += this.hScroller.visible != true ? 0 : this.hScroller.height;
  243.       var _loc4_ = _loc3_.left;
  244.       var _loc6_ = _loc3_.top;
  245.       this.back_mc.move(_loc4_,_loc6_);
  246.       this.back_mc.back_mc.setSize(this.width - _loc4_ - _loc3_.right,this.back_mc.height);
  247.       this._child0.move(_loc4_,_loc6_ + this.back_mc.height);
  248.       if(this._child0.size != mx.core.UIObject.prototype.size)
  249.       {
  250.          this._child0.setSize(this.width - _loc4_ - _loc3_.right,this.height - _loc6_ - this.back_mc.height - _loc3_.bottom);
  251.       }
  252.       this.button_mc.visible = this.closeButton == true;
  253.       this.button_mc.move(this.width - _loc4_ - _loc4_ - this.button_mc.width,(this.back_mc.height - this.button_mc.height) / 2 + _loc6_);
  254.       var _loc7_ = this.back_mc.title_mc.textHeight;
  255.       var _loc5_ = (this.back_mc.height - _loc7_ - 4) / 2;
  256.       this.back_mc.title_mc.move(_loc5_,_loc5_ - 1);
  257.       this.back_mc.title_mc.setSize(this.width - _loc5_ - _loc5_,_loc7_ + 4);
  258.    }
  259.    function createChild(id, name, props)
  260.    {
  261.       this.loadingChild = true;
  262.       var _loc3_ = super.createChild(id,name,props);
  263.       this.loadingChild = false;
  264.       return _loc3_;
  265.    }
  266.    function childLoaded(obj)
  267.    {
  268.       super.childLoaded(obj);
  269.       if(this.loadingChild)
  270.       {
  271.          this.dispatchEvent({type:"complete",current:obj.getBytesLoaded(),total:obj.getBytesTotal()});
  272.       }
  273.    }
  274. }
  275.